package com.lx.boot.web.convert.deserializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.lx.annotation.Note;
import com.lx.util.LX;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.IOException;

@AllArgsConstructor
public class DeserializerPara {

    private JsonParser jsonParser;

    private Class filedType;

    @Note("通过反射get方法获取bean的其他字段值")
    public Object getValue(){
        try {
            return jsonParser.readValueAs(filedType);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Note("通过反射get方法获取bean的其他字段值")
    public <T>T getObject(){
        return (T) jsonParser.getCurrentValue();
    }

    public JsonParser getJsonParser() {
        return jsonParser;
    }

    public Class getFiledType() {
        return filedType;
    }
}
